// AI 助手悬浮按钮
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  transition: all 0.3s ease;
  z-index: 999;

  &:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
  }

  &.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  }

  .ai-icon {
    width: 24px;
    height: 24px;
    color: white;
    display: none;
  }

  .ai-fab-text {
    color: white;
    font-size: 18px;
    font-weight: 600;
  }
}

// AI 聊天窗口
.ai-chat-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 600px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 998;
  animation: slideUp 0.3s ease;

  &.minimized {
    height: 64px;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

// 窗口头部
.chat-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  flex-shrink: 0;

  .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
  }

  .ai-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
  }

  .header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .header-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
  }

  .header-status {
    font-size: 12px;
    opacity: 0.9;
  }

  .header-actions {
    display: flex;
    gap: 8px;
  }

  .header-btn {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;

    &:hover {
      background: rgba(255, 255, 255, 0.3);
    }

    svg {
      width: 18px;
      height: 18px;
      color: white;
    }
  }
}

// 消息列表
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fb;
  display: flex;
  flex-direction: column;
  gap: 16px;

  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;

    &:hover {
      background: #ccc;
    }
  }
}

.message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-container {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;

  &.user {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  }
}

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message-bubble {
  background: white;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  max-width: 100%;
  word-wrap: break-word;

  &.loading {
    padding: 16px;
  }
}

.user-message {
  .message-container {
    flex-direction: row-reverse;
  }

  .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
  }

  .message-time {
    color: rgba(255, 255, 255, 0.8);
    text-align: right;
  }
}

.message-text {
  font-size: 14px;
  line-height: 1.6;
  color: #252b3a;
  white-space: pre-wrap;

  .user-message & {
    color: white;
  }
}

.message-time {
  font-size: 11px;
  color: #8a8e99;
  margin-top: 4px;
}

// 加载动画
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;

  span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;

    &:nth-child(2) {
      animation-delay: 0.2s;
    }

    &:nth-child(3) {
      animation-delay: 0.4s;
    }
  }
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

// 快捷问题
.quick-questions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.quick-question-label {
  font-size: 13px;
  color: #575d6c;
  font-weight: 500;
}

.quick-question-btn {
  background: white;
  border: 1px solid #e0e3e8;
  border-radius: 8px;
  padding: 10px 14px;
  text-align: left;
  font-size: 13px;
  color: #252b3a;
  cursor: pointer;
  transition: all 0.2s;

  &:hover {
    border-color: #667eea;
    background: #f8f9fb;
    color: #667eea;
  }
}

// 输入区域
.chat-input-container {
  padding: 16px 20px;
  background: white;
  border-top: 1px solid #e0e3e8;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #e0e3e8;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;

  &:focus {
    border-color: #667eea;
  }

  &:disabled {
    background: #f8f9fb;
    cursor: not-allowed;
  }

  &::placeholder {
    color: #8a8e99;
  }
}

.send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;

  &:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  }

  &:disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  svg {
    width: 20px;
    height: 20px;
    color: white;
  }
}

.input-hint {
  font-size: 11px;
  color: #8a8e99;
  margin-top: 8px;
  text-align: center;
}

// 响应式设计
@media (max-width: 768px) {
  .ai-chat-container {
    right: 12px;
    bottom: 84px;
    width: calc(100vw - 24px);
    max-width: 380px;
  }

  .ai-fab {
    right: 12px;
    bottom: 12px;
  }
}

@media (max-width: 480px) {
  .ai-chat-container {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    max-height: 600px;
  }
}
